﻿using System;
using System.Collections.Generic;

using System.Text;

namespace RoughJs.Ast
{
    public abstract class XMLObject : IdScriptableObject
    {
        public XMLObject()
        {
        }

        public XMLObject(Scriptable scope, Scriptable prototype)
            : base(scope, prototype)
        {

        }

        /// <summary>
        ///ECMAScript [[Has]].
        /// </summary>
        /// <param name="cx"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public abstract bool ecmaHas(Context cx, Object id);

        /// <summary>
        /// ECMAScript [[Get]].
        /// </summary>
        /// <param name="cx"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public abstract Object ecmaGet(Context cx, Object id);

        /// <summary>
        /// ECMAScript [[Put]]
        /// </summary>
        /// <param name="cx"></param>
        /// <param name="id"></param>
        /// <param name="value"></param>
        public abstract void ecmaPut(Context cx, Object id, Object value);

        /// <summary>
        /// [[Delete]].
        /// </summary>
        /// <param name="cx"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public abstract bool ecmaDelete(Context cx, Object id);

        /// <summary>
        /// 返回额外的对象，如果没有就返回空
        /// </summary>
        /// <param name="cx"></param>
        /// <returns></returns>
        public abstract Scriptable getExtraMethodSource(Context cx);

        /// <summary>
        /// x.@y, x..y etc.
        /// </summary>
        /// <param name="cx"></param>
        /// <param name="elem"></param>
        /// <param name="memberTypeFlags"></param>
        /// <returns></returns>
        public abstract Ref memberRef(Context cx, Object elem,
                                      int memberTypeFlags);

        /// <summary>
        ///  x::ns, x.@ns::y, x..@ns::y etc.
        /// </summary>
        /// <param name="cx"></param>
        /// <param name="namespace1"></param>
        /// <param name="elem"></param>
        /// <param name="memberTypeFlags"></param>
        /// <returns></returns>
        public abstract Ref memberRef(Context cx, Object namespace1, Object elem,
                                      int memberTypeFlags);

        /// <summary>
        /// 包装为NativeWith
        /// </summary>
        /// <param name="scope"></param>
        /// <returns></returns>
        public abstract NativeWith enterWith(Scriptable scope);

        /// <summary>
        /// .() query.
        /// </summary>
        /// <param name="scope"></param>
        /// <returns></returns>
        public abstract NativeWith enterDotQuery(Scriptable scope);

        /// <summary>
        /// 加
        /// </summary>
        /// <param name="cx"></param>
        /// <param name="thisIsLeft"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public virtual Object addValues(Context cx, bool thisIsLeft, Object value)
        {
            return ScriptableObject.NOT_FOUND;
        }
    }
}
